package eleventh.另一种比较器Comparator;

import java.util.Comparator;

//定义比较规则
public class StudentComparator implements Comparator<Student> {
    @Override
    public int compare(Student s1, Student s2) {
        if(s1.equals(s2)){
            return 0;
        }else if(s1.getAge()<s2.getAge()){
            //按照年龄比较
            return 1;
        }else{
            return -1;
        }
    }
}
